<%--
  Created by IntelliJ IDEA.
  User: Squking
  Date: 2018/5/13
  Time: 16:59
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>搜索图书</title>
</head>
<body>
    <form:form method="POST" action="/action/searchBooks">
        <h>输入查询内容</h>
        <form:input path="keywords"/>
        <form:select path="contentType">
            <form:option value="0">ISBN</form:option>
            <form:option value="1">作者</form:option>
            <form:option value="2">书名</form:option>
        </form:select>
        <form:select path="matchType">
            <form:option value="0">前方一致</form:option>
            <form:option value="1">后方一致</form:option>
            <form:option value="2">包含</form:option>
        </form:select>
        <input type="submit" value="搜索"/>
        <%--<a href="/searchBooks/${requestScope.get("contentType")}_${requestScope.get("keywords")}_${requestScope.get("contentType")}_0">搜索</a>--%>
    </form:form>
    <table border="1" cellpadding="10" cellspacing="0">
        <tr>
            <th>封面</th>
            <th>ISBN</th>
            <th>图书名称</th>
            <th>作者</th>
            <th>价格</th>
            <th>出版社</th>
            <th></th>
        </tr>

        <c:forEach items="${listBook }" var="book">
            <tr>
                <td>${book.picture }</td>
                <td>${book.ISBN }</td>
                <td>${book.name }</td>
                <td>${book.author }</td>
                <td>${book.price }</td>
                <td>${book.publish }</td>
                <td>
                    <form action="/action/addToCart/${book.ISBN}" method="post">
                        <input type="submit" value="加入购物车" />
                    </form>
                </td>
            </tr>
        </c:forEach>
    </table>
    <c:if test="${page>0}">
        <a href="/searchBooks/${page-1}">上一页</a>
    </c:if>
    <c:if test="${page<=0}">
        <a>上一页</a>
    </c:if>
    <c:if test="${page<totalPage-1}">
        <a href="/searchBooks/${page+1}">下一页</a>
    </c:if>
    <c:if test="${page>=totalPage-1}">
        <a>下一页</a>
    </c:if>
    <p>当前页: ${page + 1}, 总数: ${totalPage}</p>
    <a href="../../index.jsp">返回</a>
</body>
</html>
